﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Caca.MineSweeper.AI
{
    public class Player
    {
        public Game Game { get; private set; }
        public Analyst analyst { get; private set; }

        public event MarkEventHandler OnMark;
        public event UnCoverEventHandler OnUnCover;

        public Player(Game game)
        {
            this.Game = game;
            this.analyst = new Analyst(Mark, UnCover, game);

        }

        public void NextMove()
        {
            analyst.NextMove();
        }


        #region private

        void Mark(int x, int y)
        {
            Game.Mark(x, y);
        }

        void UnCover(int x, int y)
        {
            Plot p = Game.UnCover(x, y);

            if (OnUnCover != null)
                OnUnCover(x, y);

            analyst.Pending(x, y, p);
        }

        #endregion
    }

    public delegate void MarkEventHandler(int x, int  y);
    public delegate void UnCoverEventHandler(int x, int y);
}
